package cn.shop.ylp.service;

import cn.shop.ylp.UniqueTable;
import cn.shop.ylp.UniqueTableMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author yulianpeng
 * @email network_u@163.com
 * Date 2020/9/14
 */
@Controller
@RequestMapping("/order")
@CrossOrigin(allowCredentials = "true",allowedHeaders = "*")
public class Unique {
    @Autowired
    UniqueTableMapper uniqueTableMapper;
    public String getFourMax(){
        UniqueTable uniqueTable = uniqueTableMapper.selectByPrimaryKey(4);
        int curVa = 0;
        int r = 0;
        while (r == 0){
            curVa = uniqueTable.getCurrent();
            uniqueTable.setCurrent(curVa+1);
            r = uniqueTableMapper.updateByPrimaryKey(uniqueTable);
        }
        return String.valueOf(curVa);
    }
}
